using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.SharePoint;
using System.Globalization;

namespace TST.SharePoint.Shared
{
    public class WSSFieldBoolean : FieldBoolean
    {
        /// <summary>
        /// Constructor.
        /// </summary>
        public WSSFieldBoolean()
        {
        }

        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="ID">The ID for the field.</param>
        public WSSFieldBoolean(string Id)
            : base(Id)
        {
        }

        public override object GetTypedValue(object value)
        {
            if (value == null)
                return null;
            return ((!string.IsNullOrEmpty(value.ToString())) && (value.ToString() == "1"));
        }

        public override string GetTypedValueAsString(object value)
        {
            if (value == null)
                return null;
            if ((bool)value)
                return "1";
            return "0";
        }

        public override string GetTypedValueFormatted(object value)
        {
            if (value == null)
                return null;
            return ((bool)value).ToString(new CultureInfo(1033));
        }

    }
}
